#include <omp.h>
#include <stdio.h>

int a, b, i, tid;
float x;
#pragma omp threadprivate(a, x)

int threadPrivate(void)
{
	omp_set_dynamic(0);

	printf("1st parallel region:\n");
#pragma omp parallel private(b, tid)
	{
		tid = omp_get_thread_num();
		a = tid;
		b = tid;
		x = 1.1 * tid + 1.0;
		printf("Thread %d:   a,b,x= %d %d %f\n", tid, a, b, x);
	} /* end of parallel section */

	printf("************************************\n");
	printf("Master thread doing serial work here\n");
	printf("The a,b,x=%d %d %f\n", a, b, x);
	printf("************************************\n");

	printf("2nd Parallel Region:\n");

#pragma omp parallel private(tid)
	{
		tid = omp_get_thread_num();
		printf("Thread %d:   a,b,x= %d %d %f\n", tid, a, b, x);
	} /* end of parallel section */

	printf("Master thread:\n");
	printf("The a,b,x=%d %d %f\n", a, b, x);

	return 0;
}

